import request from '../utils/request'

export const informationApi = {
  /** 获取资讯分类 */
  getInformationCategories() {
    return request.get('/info/categories')
  },
  /** 获取资讯分类列表 */
  getInformationCategoriesList(params: any) {
    return request.get('/infos', { params })
  },
  /** 获取资讯详情 */
  getInformationDetail(id: any) {
    const params = {
      with: 'author,category',
    }
    return request.get(`/infos/${id}`, { params })
  },
  /** 获取资讯评论 */
  getInformationComment(id: any, params: any) {
    return request.get(`/infos/${id}/comments`, { params })
  },
  /** 收藏资讯 */
  collectInfo(id: any) {
    return request.put(`/infos/${id}/favorite`)
  },
  /** 取消收藏资讯 */
  deleteCollectInfo(id: any) {
    return request.delete(`/infos/${id}/favorite`)
  },
  /** 点赞资讯 */
  likeInfo(id: any) {
    return request.put(`/infos/${id}/like`)
  },
  /** 取消收藏资讯 */
  deleteLikeInfo(id: any) {
    return request.delete(`/infos/${id}/like`)
  },
}
